package lumis.service.comment;

import lumis.content.ContentManagerFactory;
import lumis.content.core.ContentVersion;
import lumis.content.service.DetailsUtil;
import lumis.doui.control.inputtext.InputHiddenControl;
import lumis.portal.PortalException;

/**
 * It stores the current content locale identifier in itself.
 * 
 * @version $Revision: 10458 $ $Date: 2009-06-02 15:49:09 -0300 (Tue, 02 Jun 2009) $
 * @since 4.2.0
 */
public class CurrentContentLocaleIdControl extends InputHiddenControl
{
	@Override
	public void setRenderData() throws PortalException
	{
		// if could not obtain the value normally, try to use DetailsUtil
		if (getValue() == null)
		{
			String itemId = DetailsUtil.getCurrentItemId();
			if (itemId != null)
			{
				ContentVersion contentVersion = ContentManagerFactory.getContentManager().getContentVersionByItemId(itemId);
				setValue(contentVersion.getContentLocale().getId());
			}
		}
		
		super.setRenderData();
	}
}
